package com.ss.web.tagmark.init;

import javax.servlet.http.HttpServletRequest;

import org.springframework.security.web.authentication.WebAuthenticationDetails;

import com.ss.web.tagmark.utils.IpUtils;

/**
 * 自定义的可以带一些额外信息的功能
 *
 * @author taofucheng
 *
 */
public class SecurityWebAuthenticationDetails extends WebAuthenticationDetails {
	/**
	 *
	 */
	private static final long serialVersionUID = 6975601077710753878L;
	private final String realIp;

	public SecurityWebAuthenticationDetails(HttpServletRequest request) {
		super(request);
		realIp = IpUtils.getRemoteIp(request);
	}

	public String getRealIp() {
		return realIp;
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(super.toString()).append("; realIp: ").append(this.getRealIp());
		return sb.toString();
	}
}